iOS-学习之MPMediaItem 发表于 2017-02-12 | 分类于 blog | | 阅读次数: iOS媒体库文件信息的Item。 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221NS_ASSUME_NONNULL_BEGIN@class NSImage, UIImage, MPMediaItemArtwork;typedef NS_OPTIONS(NSUInteger, MPMediaType) { // audio MPMediaTypeMusic = 1 << 0, // 音乐 MPMediaTypePodcast = 1 << 1, // 音频播客 MPMediaTypeAudioBook = 1 << 2, // 音频书 MPMediaTypeAudioITunesU MP_API(ios(5.0), macos(10.12.2)) = 1 << 3, // iTunes U音频课 MPMediaTypeAnyAudio = 0x00ff, // 任何类型的音频 // video MPMediaTypeMovie MP_API(ios(5.0), macos(10.12.2)) = 1 << 8, // 电影 MPMediaTypeTVShow MP_API(ios(5.0), macos(10.12.2)) = 1 << 9, // 电视节目 MPMediaTypeVideoPodcast MP_API(ios(5.0), macos(10.12.2)) = 1 << 10, // 播客视频 MPMediaTypeMusicVideo MP_API(ios(5.0), macos(10.12.2)) = 1 << 11, // 音乐视频 MPMediaTypeVideoITunesU MP_API(ios(5.0), macos(10.12.2)) = 1 << 12, // iTunes U视频课 MPMediaTypeHomeVideo MP_API(ios(7.0), macos(10.12.2)) = 1 << 13, // 家庭视频 MPMediaTypeAnyVideo MP_API(ios(5.0), macos(10.12.2)) = 0xff00, // 任何视频 MPMediaTypeAny = ~0UL // 未指定的媒体视频内容} MP_API(ios(3.0), tvos(9.0), macos(10.12.2));// An MPMediaItem represents a single piece of media in an MPMediaLibrary.// Media items have a unique identifier which persists across application launches.MP_API(ios(3.0))MP_PROHIBITED(tvos, macos)@interface MPMediaItem : MPMediaEntity#pragma mark - Properties// Properties marked filterable can also be used to build MPMediaPropertyPredicates (see MPMediaQuery.h).// 获取媒体项持久标识符MP_EXTERN NSString * const MPMediaItemPropertyPersistentID MP_API(ios(4.2), macos(10.12.2)); // filterable@property (nonatomic, readonly) MPMediaEntityPersistentID persistentID MP_API(ios(5.0));// 获取媒体类型MP_EXTERN NSString * const MPMediaItemPropertyMediaType; // filterable@property (nonatomic, readonly) MPMediaType mediaType MP_API(ios(7.0));// 获取媒体项目的标题MP_EXTERN NSString * const MPMediaItemPropertyTitle; // filterable@property (nonatomic, readonly, nullable) NSString *title MP_API(ios(7.0));// 获取专辑名称MP_EXTERN NSString * const MPMediaItemPropertyAlbumTitle; // filterable@property (nonatomic, readonly, nullable) NSString *albumTitle MP_API(ios(7.0));// 获取专辑项目持久标识符MP_EXTERN NSString * const MPMediaItemPropertyAlbumPersistentID MP_API(ios(4.2), macos(10.12.2)); // filterable@property (nonatomic, readonly) MPMediaEntityPersistentID albumPersistentID MP_API(ios(8.0));// 获取媒体或专辑的表演艺术家MP_EXTERN NSString * const MPMediaItemPropertyArtist; // filterable@property (nonatomic, readonly, nullable) NSString *artist MP_API(ios(7.0));// 获取艺术家持久标识符MP_EXTERN NSString * const MPMediaItemPropertyArtistPersistentID MP_API(ios(4.2), macos(10.12.2)); // filterable@property (nonatomic, readonly) MPMediaEntityPersistentID artistPersistentID MP_API(ios(8.0));// 专辑的主要表演艺术家MP_EXTERN NSString * const MPMediaItemPropertyAlbumArtist; // filterable@property (nonatomic, readonly, nullable) NSString *albumArtist MP_API(ios(7.0));// 获取专辑的主要表演艺术家的持久标识符MP_EXTERN NSString * const MPMediaItemPropertyAlbumArtistPersistentID MP_API(ios(4.2), macos(10.12.2)); // filterable@property (nonatomic, readonly) MPMediaEntityPersistentID albumArtistPersistentID MP_API(ios(8.0));// 获取媒体项目类型MP_EXTERN NSString * const MPMediaItemPropertyGenre; // filterable@property (nonatomic, readonly, nullable) NSString *genre MP_API(ios(7.0));// 获取媒体项目类型的持久标识符MP_EXTERN NSString * const MPMediaItemPropertyGenrePersistentID MP_API(ios(4.2), macos(10.12.2)); // filterable@property (nonatomic, readonly) MPMediaEntityPersistentID genrePersistentID MP_API(ios(8.0));// 获取媒体音乐的作曲家MP_EXTERN NSString * const MPMediaItemPropertyComposer; // filterable@property (nonatomic, readonly, nullable) NSString *composer MP_API(ios(7.0));// 获取媒体音乐的作曲家的持久标识符MP_EXTERN NSString * const MPMediaItemPropertyComposerPersistentID MP_API(ios(4.2), macos(10.12.2)); // filterable@property (nonatomic, readonly) MPMediaEntityPersistentID composerPersistentID MP_API(ios(8.0));// 获取媒体项目持续播放时长MP_EXTERN NSString * const MPMediaItemPropertyPlaybackDuration;@property (nonatomic, readonly) NSTimeInterval playbackDuration MP_API(ios(7.0));// 媒体项目的曲目编号MP_EXTERN NSString * const MPMediaItemPropertyAlbumTrackNumber;@property (nonatomic, readonly) NSUInteger albumTrackNumber MP_API(ios(7.0));// 包含媒体项的相册中的曲目数MP_EXTERN NSString * const MPMediaItemPropertyAlbumTrackCount;@property (nonatomic, readonly) NSUInteger albumTrackCount MP_API(ios(8.0));// 媒体项的磁盘号码,用于多个唱片集的一部分的媒体项MP_EXTERN NSString * const MPMediaItemPropertyDiscNumber;@property (nonatomic, readonly) NSUInteger discNumber MP_API(ios(7.0));// 包含媒体项的相册中的磁盘数MP_EXTERN NSString * const MPMediaItemPropertyDiscCount;@property (nonatomic, readonly) NSUInteger discCount MP_API(ios(8.0));// 媒体项目的原图图像MP_EXTERN NSString * const MPMediaItemPropertyArtwork MP_API(ios(3.0), macos(10.13.2));@property (nonatomic, readonly, nullable) MPMediaItemArtwork *artwork MP_API(ios(7.0));// 是否有歌词或语言MP_EXTERN NSString * const MPMediaItemPropertyIsExplicit MP_API(ios(7.0), macos(10.12.2));@property (nonatomic, readonly, getter = isExplicitItem) BOOL explicitItem MP_API(ios(10.0));// 媒体项目的歌词MP_EXTERN NSString * const MPMediaItemPropertyLyrics;@property (nonatomic, readonly, nullable) NSString *lyrics MP_API(ios(8.0));// 媒体项目是否是编译的一部分MP_EXTERN NSString * const MPMediaItemPropertyIsCompilation; // filterable@property (nonatomic, readonly, getter = isCompilation) BOOL compilation MP_API(ios(8.0));// 媒体项目发布日期MP_EXTERN NSString * const MPMediaItemPropertyReleaseDate MP_API(ios(4.0), macos(10.12.2));@property (nonatomic, readonly, nullable) NSDate *releaseDate MP_API(ios(7.0));// 媒体项目每分钟的音乐节拍数MP_EXTERN NSString * const MPMediaItemPropertyBeatsPerMinute MP_API(ios(4.0), macos(10.12.2));@property (nonatomic, readonly) NSUInteger beatsPerMinute MP_API(ios(8.0));// 媒体项目的文本信息MP_EXTERN NSString * const MPMediaItemPropertyComments MP_API(ios(4.0), macos(10.12.2));@property (nonatomic, readonly, nullable) NSString *comments MP_API(ios(8.0));// 指向媒体项的urlMP_EXTERN NSString * const MPMediaItemPropertyAssetURL MP_API(ios(4.0), macos(10.12.2));@property (nonatomic, readonly, nullable) NSURL *assetURL MP_API(ios(8.0));// 媒体项是否是iCloud音乐库项目MP_EXTERN NSString * const MPMediaItemPropertyIsCloudItem MP_API(ios(6.0), macos(10.12.2)); // filterable@property (nonatomic, readonly, getter = isCloudItem) BOOL cloudItem MP_API(ios(8.0));// 媒体项目是否有保护权MP_EXTERN NSString * const MPMediaItemPropertyHasProtectedAsset MP_API(ios(9.2), macos(10.12.2)); // filterable@property (nonatomic, readonly, getter = hasProtectedAsset) BOOL protectedAsset MP_API(ios(9.2));// 播客的标题MP_EXTERN NSString * const MPMediaItemPropertyPodcastTitle; // filterable@property (nonatomic, readonly, nullable) NSString *podcastTitle MP_API(ios(7.0));// 音频播客的持久标识符MP_EXTERN NSString * const MPMediaItemPropertyPodcastPersistentID MP_API(ios(4.2), macos(10.12.2)); // filterable@property (nonatomic, readonly) MPMediaEntityPersistentID podcastPersistentID MP_API(ios(8.0));// 媒体项目的播放次数MP_EXTERN NSString * const MPMediaItemPropertyPlayCount; // filterable@property (nonatomic, readonly) NSUInteger playCount MP_API(ios(7.0));// 用户跳过该项目的次数MP_EXTERN NSString * const MPMediaItemPropertySkipCount;@property (nonatomic, readonly) NSUInteger skipCount MP_API(ios(7.0));// 用户的评级 [1……5]MP_EXTERN NSString * const MPMediaItemPropertyRating;@property (nonatomic, readonly) NSUInteger rating MP_API(ios(7.0));// 上次播放媒体项目的日期MP_EXTERN NSString * const MPMediaItemPropertyLastPlayedDate;@property (nonatomic, readonly, nullable) NSDate *lastPlayedDate MP_API(ios(7.0));// 媒体项目分组信息MP_EXTERN NSString * const MPMediaItemPropertyUserGrouping MP_API(ios(4.0), macos(10.12.2));@property (nonatomic, readonly, nullable) NSString *userGrouping MP_API(ios(8.0));// 用户最近出现在媒体项目中的位置MP_EXTERN NSString * const MPMediaItemPropertyBookmarkTime MP_API(ios(6.0), macos(10.12.2));@property (nonatomic, readonly) NSTimeInterval bookmarkTime MP_API(ios(7.0));// 媒体项目的添加日期MP_EXTERN NSString * const MPMediaItemPropertyDateAdded MP_API(ios(10.0), macos(10.12.2));@property (nonatomic, readonly) NSDate *dateAdded MP_API(ios(10.0));// Matches the id used by MPMusicPlayerController to enqueue store tracksMP_EXTERN NSString * const MPMediaItemPropertyPlaybackStoreID MP_API(ios(10.3));@property (nonatomic, readonly) NSString *playbackStoreID MP_API(ios(10.3));@end//-----------------------------------------------------MP_API(ios(3.0), tvos(9.0), macos(10.12.2))@interface MPMediaItemArtwork : NSObject#if TARGET_OS_IPHONE// 初始化艺术品媒体项目图片的大小- (instancetype)initWithBoundsSize:(CGSize)boundsSize requestHandler:(UIImage *(^)(CGSize size))requestHandler NS_DESIGNATED_INITIALIZER MP_API(ios(10.0), tvos(10.0));// Returns the artwork image for an item at a given size (in points).- (nullable UIImage *)imageWithSize:(CGSize)size;#else- (instancetype)initWithBoundsSize:(CGSize)boundsSize requestHandler:(NSImage *(^)(CGSize size))requestHandler NS_DESIGNATED_INITIALIZER MP_API(ios(10.12.2));// Returns the artwork image for an item at a given size (in points).- (nullable NSImage *)imageWithSize:(CGSize)size MP_API(ios(10.12.2));#endif@property (nonatomic, readonly) CGRect bounds; // The bounds of the full size image (in points).#endif- (id)init NS_UNAVAILABLE;@endNS_ASSUME_NONNULL_END